#include <iostream>
#include <vector>
#include <assert.h>
#include <limits.h>

class FenwickTree
{

    std::vector<int> tree;
    
private:
    
    size_t nextValueIterator (size_t i)
    {
        return (i-1)&i;
    }
    
    size_t nextAddIterator (size_t i)
    {
        return i|(i+1);
    }
    
    int sum (size_t x)
    {
        int value = 0;
        for (size_t i = x+1; i > 0; i = nextValueIterator(i))
            value += tree[i-1];
        return value;
    }
    
public:
    
    explicit FenwickTree (std::vector<int> data)
    {
        tree.assign(data.size(), 0);
        for (int i = 0; i < data.size(); ++i)
            add (data[i], i);
    }
    
    int getSum (size_t x1, size_t x2)
    {
        assert (x1 <= x2);
        return ( sum(x2) - sum(x1 - 1) );
    }
    
    
    void add (int add, size_t x)
    {
        for (size_t i = x; i < tree.size(); i = nextAddIterator(i))
            tree[i] += add;
    }
    
};

int main(){

    std::vector<int> data;
    int n, minToShift = INT_MAX, input;
    //сдвинем числа на min, чтобы они были перестановкой 0..n-1
    
    std::cin >> n;
    for (int i = 0; i < n; ++i)
    {
        std::cin >> input;
        if (input < minToShift)
            minToShift = input;
        data.push_back(input);
    }
    std::vector<int> inversions(data.size(), 0);
    FenwickTree tree(inversions);
    
    int steps = 0;
    for (int i = 0; i < data.size(); ++i)
    {
        steps += i - tree.getSum(0, data[i]-minToShift);
        tree.add(1, data[i]-minToShift);
    }
    
    std::cout << "\n" << steps;

    return 0;
}